/*
 * TCCC 04 Qual Set 1
 */

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;


public class Surveyor
{
    int[] x, y;
    public int area2 (int i, int j) {
	int x1 = x[i], x2 = x[j], y1 = y[i], y2 = y[j];
	return x2*y1 - x1*y2;
    }

    public int area(String direction, int[] length)
    {
	int n = direction.length ();
	x = new int[n+1];
	y = new int[n+1];
	x[0] = 0;
	y[0] = 0;
	for (int i = 0; i < n; ++i) {
	    char c = direction.charAt (i);
	    int l = length[i];
	    x[i+1] = x[i];
	    y[i+1] = y[i];
	    switch (c) {
	    case 'N':
		y[i+1] = y[i] + l;
		break;
	    case 'E':
		x[i+1] = x[i] + l;
		break;
	    case 'S':
		y[i+1] = y[i] - l;
		break;
	    case 'W':
		x[i+1] = x[i] - l;
		break;
	    }
	}
	int area = 0;
	for (int i = 1; i < n; ++i)
	    area += area2 (i, i + 1);
	return Math.abs (area)/2;
    }
    
    <%:testing-code%>
}
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!